package com.example.financechain.controller;


import com.alibaba.fastjson.JSON;
import com.example.financechain.Utils.JsonData;
import com.example.financechain.common.cache.Cache;
import com.example.financechain.config.CacheKeyManager;
import com.example.financechain.domain.DTO.DetailDTO;
import com.example.financechain.domain.entity.Blockexplore;
import com.example.financechain.service.IBlockexploreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.ws.rs.GET;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yy
 * @since 2023-04-24
 */
@RestController
@RequestMapping("private/blockexplore")
public class BlockexploreController {

    @Autowired
    private IBlockexploreService iBlockexploreService;

    /**
     * 获取区块列表
     * @return
     */
    @Cache(name = CacheKeyManager.BLOCKINFO)
    @GetMapping("/blocklist")
    public JsonData explore(){
        //List<Blockexplore> blockexploreList = iBlockexploreService.list();

        return  iBlockexploreService.blocklist();
    }

    /**
     * 根据交易ID查询区块记录的信息
     * @return
     */
    @PostMapping("/detail")
    public JsonData querydetail(@RequestBody DetailDTO detailDTO){

       return iBlockexploreService.queryBlockdetail(detailDTO);
    }

}
